package com.yyds.controller;

import com.yyds.common.MyJSON;
import com.yyds.common.R;
import com.yyds.pojo.TravelStaff;
import com.yyds.service.TravelStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("/admin/travelstaff")
public class TravelStaffController {
    @Autowired
    private TravelStaffService travelStaffService;

    //    添加确诊人员信息
    @RequestMapping("/addtravelstaff")
    public R addtravelstaff(TravelStaff travelStaff){
        int result = travelStaffService.addtravelstaff(travelStaff);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error().message("登录失败");
        }
    }
    //    删除确诊人员信息
    @RequestMapping("/deletetravelstaff")
    public R deletetravelstaff(Integer staff_id){

        int result = travelStaffService.deletetravelstaff(staff_id);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }
    //    确诊人员信息部分删除
    @RequestMapping("/deletestravelstaffs")
    public R deletestravelstaff(String str) {
        System.out.println("deletestravelstaff str" + str);
        Integer i = travelStaffService.deletestravelstaffs(str);
        return i > 0 ? R.ok() : R.error();
    }
    //    确诊人员信息信息更新
    @RequestMapping("/updatetravelstaff")
    public R updatetravelstaff(TravelStaff travelStaff){
        int result = travelStaffService.updatetravelstaff(travelStaff);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }
    //    确诊人员信息列表查询
    @RequestMapping("/queryalltravelstaff")
    public MyJSON<TravelStaff> queryalltravelstaff(@RequestParam Map<String,Object> queryall){

        return travelStaffService.queryalltravelstaff(queryall);
    }

    //    确诊人员详细信息列表查询
    @RequestMapping("/queryalltravelstaffs")
    public MyJSON<TravelStaff> queryalltravelstaffs(@RequestParam Map<String,Object> queryall){

        MyJSON<TravelStaff> queryalltravelstaffs = travelStaffService.queryalltravelstaffs(queryall);
        System.out.println("queryalltravelstaffs = " + queryalltravelstaffs);
        return queryalltravelstaffs;
    }

}
